from PyQt4.QtGui import QWidget, QSlider, QLabel, QGridLayout
#from PyQt4 import QtGui
from PyQt4.QtCore import Qt, SIGNAL

class ControlWidget(QWidget):
	def __init__(self, container):
		QWidget.__init__(self, container)

		l = QGridLayout(self)
		self.setLayout(l)

		title = QLabel("Simulatore (quasi)realistico di elettrocardiogramma \ne variabilita' del battito sanguigno \nper macchine automatiche.\n\n")
		l.addWidget(title)

		self.slider = self.createSlider(self)
		l.addWidget(self.slider)
		self.sliderLabel = QLabel("Grado di stress: 0%")
		self.setNum(0)
		l.addWidget(self.sliderLabel )
		self.connect(self.slider, SIGNAL('valueChanged(int)'), self.setNum)

		self.lastTossed = QLabel("Last tossed: ")
		l.addWidget(self.lastTossed)

		self.lastRR = QLabel("Last RR: ")
		l.addWidget(self.lastRR)
	
	def createSlider(self, parent):
		slider = QSlider(Qt.Horizontal)
		#slider = QSlider(1, parent)
		return slider

	def setNum(self, val):
		self.sliderLabel.setText("Grado di stress: " + str(val/100.0)+'%')
		self.value = val

	def setLastRR(self, n):
		self.lastRR.setText("Last RR: "+str(n))
	def setLastTossed(self, n):
		self.lastTossed.setText("Last tossed: "+n)

if __name__ == "__main__":
	import main
